﻿#ifndef SLABEL_H
#define SLABEL_H

#include <QLabel>

enum enumAlign_Mode
{
    Align_Left = 0x00,
    Align_Center = 0x01,
    Align_Right = 0x02,
};

enum enumObj_Type
{
    Obj_Text = 0x00,
    Obj_Image = 0x01
};

class SLabel : public QLabel
{
    Q_OBJECT
public:
    SLabel(QWidget* parent = NULL);

public slots:
    void setText(const QString&);
    void setImage(const QString& strImgFile);
    void setFontSize(int nFontSize);
    void setAlign(enumAlign_Mode nAlign_Mode);

protected:
    virtual void paintEvent(QPaintEvent* e);
    virtual void resizeEvent(QResizeEvent* e);

    void upateLabel();

private:

    enumObj_Type m_Obj_Type = Obj_Text;
    enumAlign_Mode m_nAlign = Align_Center;

    int     m_nFontSize;
    QString m_strImgFile;

    QImage        *m_pImage;
    QRect         m_srcRect;
    QRect         m_dstRect;

    QFont m_ft;

    int m_nImgScale;
    int m_nActImgWidth;
    int m_nActImgHeight;
};

#endif // MLABEL_H
